class Solution {
public:
    /*
    1、整体翻转
    2、对区间[0,size-1-n]翻转
    3、对区间[size-n,size-1]翻转
    */
    string LeftRotateString(string str, int n) {
        myreverse(str, 0, str.size()-1);
        myreverse(str, 0, str.size()-1-n);
        myreverse(str,str.size()-n, str.size()-1);
        return str;
    }
    void myreverse(string &str,int start,int end)
    {
        char tmp;
        while(start<end)
        {
            tmp=str[start];
            str[start]=str[end];
            str[end]=tmp;
            start++;
            end--;
        }
    }
};